<?php $this->_extends('../_layouts/blank_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.js"></script>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript">
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
	$("#save_btn").click(function(){
		var can_save = 1;
		$(".list_table").find("input[name$='actual_quantity]']").each(function(){
			if (parseInt($(this).val())>parseInt($(this).parent().prev().text()))
			{
				can_save=0;
				alert("实际数不能超过预计数！");
				return false;
			}
		});
		if (can_save)
		{
			$("form").submit();
		}
	});
});
</script>
<h3><?=Helper_BSS_Normal::getIniOne('purchase_order_type', 'value', $purchase_order['type'], 'name')?></h3>
<form method="post" action="<?=url('Storage::DFOverseas/ActualQuantityEditSave')?>">
<table class="form_table">
<tr>
	<th>单号</th>
	<td>
	<?=$purchase_order['number']?>
	<input type="hidden" name="purchase_order_id" value="<?=$purchase_order['id']?>" />	
	</td>
	<th>经手人员</th>
	<td><?=$purchase_order['purchase_user_name']?></td>
</tr>
<tr>
	<th>日期</th>
	<td><?=$purchase_order['purchase_time']?></td>
	<th>实际总价</th>
	<td><?=sprintf('%.2f', $purchase_order['actual_amount'])?></td>
</tr>
<tr>
	<th>仓库</th>
	<td><?=$purchase_order['warehouse_name']?></td>
	<th>结款类型</th>
	<td><?=Helper_BSS_Normal::getIniOne('purchase_order_payment_type','value',$purchase_order['payment_type'],'name')?></td>
</tr>
<tr>
	<th>备注</th>
	<td colspan="3"><textarea rows="3" cols="70" disabled="disabled"><?=$purchase_order['notes']?></textarea></td>
</tr>
</table>
<table width="100%" class="list_table">
<tr>
	<th width="100">图片</th>
	<th width="50">产品编号</th>
	<th width="180">产品名称</th>
	<th width="40">预计数</th>
	<th width="40">实际数</th>
	<th width="50">当前库存</th>
	<th width="70">架位</th>
	<th width="50">产品特点</th>
	<th width="100">包材</th>
	<th width="60">标签贴</th>
	<th width="60">重量G</th>
	<th width="60">申报价值$</th>
	<th width="80">申报名称CN</th>
	<th width="80">申报名称EN</th>
	<th>备注</th>
</tr>
<?foreach ($item as $i):?>
<tr>
	<td>
		<?if ($i['pic_url']):?>
			<?$pretty_photo_number = 0;?>
			<?foreach ($i['pic_url'] as $ip):?>
			<a rel="pretty_photo[<?=$i['id']?>]" href="<?=$ip?>"><?if(!$pretty_photo_number):?><img src="<?=$i['pic_url'][0]?>" height="100" /><?endif;?></a>
			<?$pretty_photo_number = 1;?>
			<?endforeach;?>
		<?endif;?>
	</td>
	<td>
		<?=$i['product_number']?>
		<input type="hidden" name="item[<?=$i['id']?>][product_number]" value="<?=$i['product_number']?>" />	
	</td>
	<td align="left"><?=$i['product_name']?></td>
	<td align="left"><?=intval($i['budget_quantity'])?></td>
	<td align="left">
		<input type="text" name="item[<?=$i['id']?>][actual_quantity]" value="<?=$i['actual_quantity'];?>" size="3" />
		<input type="hidden" name="item[<?=$i['id']?>][budget_quantity]" value="<?=$i['budget_quantity']?>" />
		<input type="hidden" name="item[<?=$i['id']?>][product_basic_id]" value="<?=$i['product_basic_id']?>" />
	</td>
	<td><?=$i['product_warehouse_actual_quantity']?></td>
	<td><?=$i['shelf_position']?></td>
	<td><?=trim($i['product_feature'])?></td>
	<td>
	<?foreach ($material as $m):?>
	<?if ($m['number'] == $i['material_number']):?>
	<?=$m['number'] . '-' . $m['name']?>
	<?endif;?>
	<?endforeach;?>
	</td>
	<td><?=Helper_BSS_Normal::getIniOne('product_warehouse_tag', 'value', $i['tag'], 'name')?></td>
	<td style="<?if(!floatval($i['weight'])):?>background-color: #B6DFB5;<?endif;?>"><?=$i['weight']?></td>
	<td style="<?if(!floatval($i['declared_value'])):?>background-color: #B6DFB5;<?endif;?>"><?=$i['declared_value']?></td>
	<td style="<?if(!trim($i['declared_name_cn'])):?>background-color: #B6DFB5;<?endif;?>"><?=$i['declared_name_cn']?></td>
	<td style="<?if(!trim($i['declared_name_en'])):?>background-color: #B6DFB5;<?endif;?>"><?=$i['declared_name_en']?></td>
	<td><?=$i['notes']?></td>
</tr>
<?endforeach;?>
</table>
<br />
<div align="center"><input type="button" class="button" id="save_btn" value="保存" /><input type="hidden" name="<?=Q::ini('unique_token_name');?>" value="<?=Helper_BSS_Normal::genToken();?>"/></div>
</form>
<?php $this->_endblock();?>